/*
 * Events class
 * This is an abstract class representing an Event which had private members to specify the delay from which the Event runs,
 * The amount of time an Event has already run, the thread, a reference to the commanding
 * GreenhouseControls instance, and a boolean which specifies if the thread had finished its action.
 * Implements Runnable for threading control.
 * 
 * James Zhang
 * ID: 3069886
 * July 17, 2012
 */
//Imports the necessary java packages
import java.io.*;

public @SuppressWarnings( "serial" )
abstract class Event implements Runnable, Serializable
{
    //Delay time to wait on Event
    protected final long delay;
    //Time already run by the Event
    protected long timePassed = 0;
    //Thread
    protected transient Thread thread;
    //Specifies whether the action of event has been run
    private boolean threadDeath = false;
    //Reference to the commanding GreenhouseControls instance
    protected GreenhouseControls gc = null;

    /**
     * Default Constructor which sets delayTime and starts the thread
     *
     * @param g - Passed in the governing GreenhouseControls object reference
     * @param delayTime - Time to delay the Event
     */
    public Event( GreenhouseControls g, long delayTime )
    {
        gc = g;
        delay = delayTime;
        thread = new Thread( this );
    }

    /**
     * Run method inherited from Runnable. Overridden in individual events
     */
    public synchronized void run()
    {
    }

    /**
     * Modifer which sets the threadDeath member
     *
     * @param b - Boolean which sets the threadDeath member
     */
    public void setThread( boolean b )
    {
        threadDeath = b;
    }

    /**
     * Accessor for threadDeath
     *
     * @return - returns threadDeath
     */
    public boolean getThread()
    {
        return threadDeath;
    }
} ///:~
